export default {
  sortDictionary() {
    if (
      window.navigator.userAgent.match(
        /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
      )
    ) {
      return true; // 移动端
    } else {
      return false; // PC端
    }
  },
  tanHtml(str) {
    return str
      .replace(str ? /&(?!#?\w+;)/g : /&/g, "&amp;")
      .replace(/<video.*?(?:>|\/>)/gi, "")
      .replace(/&lt;/g, "<")
      .replace(/&gt;/g, ">")
      .replace(/&quot;/g, '"')
      .replace(/&#39;/g, "'")
      .replace(/&amp;nbsp;/g, "\u3000");
  },
  // 时间判断
  filtertime(val){
    if (val) {
      let time = Number(val);
      if (null != time && "" !== time) {
        if (time >= 60 && time < 60 * 60) {
          let minute = parseInt(time / 60.0) + '';
          let second = parseInt((parseFloat(time / 60.0) - parseInt(time / 60.0)) * 60) + '';
          time = minute.padStart(2, '0') + ':' + second.padStart(2, '0');
        } else if (time >= 60 * 60 && time < 60 * 60 * 24) {
          let hour = parseInt(time / 3600.0) + '';
          let minute = parseInt((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60) + '';
          let second = parseInt((parseFloat((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60) -
            parseInt((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60)) * 60) + '';
          time = hour.padStart(2, '0') + ':' + minute.padStart(2, '0') + ':' + second.padStart(2, '0');
        } else {
          let temp = parseInt(time) + '';
          time = temp.padStart(5, '00:00');
        }
      } else {
        time = "00:00";
      }
      return time;
    } else {
      return "00:00"
    }
  }
}

